NCopiesOf Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Creates an IEnumerator that enumerates a given item n times.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<T> NCopiesOf<T>(
	int n,
	T item
)
Visual Basic (Declaration)
Public Shared Function NCopiesOf(Of T) ( _
	n As Integer, _
	item As T _
) As IEnumerable(Of T)
Visual C++
public:
generic<typename T>
static IEnumerable<T>^ NCopiesOf (
	int n, 
	T item
)

Parameters

n
Int32
The number of times to enumerate the item.
item
T
The item that should occur in the enumeration.

Return Value

An IEnumerable<T> that yields n copies of item.

Type Parameters

T

Examples

The following creates a list consisting of 1000 copies of the double 1.0.
 Copy imageCopy Code
            List<double> list = new List<double>(Algorithms.NCopiesOf(1000, 1.0));
            

Exceptions

ExceptionCondition
System..::ArgumentOutOfRangeExceptionThe argument n is less than zero.

See Also